package com.zy.drug.controller;


import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.EasyExcel;
import com.github.pagehelper.PageInfo;
import com.zy.drug.pojo.DrugInfo;
import com.zy.drug.pojo.DrugInfoExcelVo;
import com.zy.drug.service.DrugInfoService;
import com.zy.drug.vo.ReqVo;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Iterator;

@RestController
@RequestMapping("/excel")
public class ExcelController {

    @Autowired
    private DrugInfoService drugInfoService;

    @PostMapping("/queryAll")
    public PageInfo<DrugInfo> queryAll(@RequestBody ReqVo reqVo) {

        return drugInfoService.queryForPage(reqVo);

    }
    @PostMapping("/upload")
    public String uploadExcelFile3(@RequestParam("file") MultipartFile file) throws IOException {
        InputStream fis = file.getInputStream();
        EasyExcel.read(fis, DrugInfoExcelVo.class, new DrugInfoExcelListener()).sheet().doRead();
        return "解析完成";
    }
}
